import axios from 'axios'


const baseURL = 'http://localhost:8080'
const AxiosRequest = axios.create({
    baseURL: baseURL, // url = base url + request url
    timeout: 10000, // request timeout
    headers: {
        'Content-Type': 'application/json;charset=UTF-8'
    }
})

AxiosRequest.interceptors.request.use(
    config => {
        return config
    },
    error => {
        return Promise.reject(error)
    },
)

AxiosRequest.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response
        }
    },
    error => {
        return Promise.reject(error)
    },
)

export { AxiosRequest, baseURL }